package org.example.back.controller.Forum;

import org.example.back.entity.Forum.ForumComment;
import org.example.back.service.Forum.ForumCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/forum/comments")
public class ForumCommentController {

    @Autowired
    private ForumCommentService forumCommentService;

    @PostMapping
    public String addComment(@RequestBody ForumComment comment) {
        forumCommentService.addComment(comment);
        return "评论成功";
    }

    @GetMapping("/post/{postId}")
    public List<ForumComment> getComments(@PathVariable Long postId) {
        return forumCommentService.getCommentsByPostId(postId);
    }

    @DeleteMapping("/{id}")
    public String deleteComment(@PathVariable Long id) {
        forumCommentService.deleteComment(id);
        return "删除成功";
    }
}

